package goover.unit03;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMapDemo01 {
    public static void main(String[] args){
        Map map = new HashMap();
        map.put("1","Jack");
        map.put("2","Tom");
        map.put("3","Lucy");
        map.put("1","Jack");
        map.put("4","Rose");
        Set keyset = map.keySet();
        Iterator iterator = keyset.iterator();
        while (iterator.hasNext()){
            Object key = iterator.next();
            System.out.println(map.get(key));
        }
        System.out.println("-----------------------");
        Set eny = map.entrySet();
        Iterator iterator1 = eny.iterator();
        while (iterator1.hasNext()){
            Map.Entry entry = (Map.Entry) iterator1.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key +" : " + value);
        }
        System.out.println("-----------------------");
        System.out.println(map);
        System.out.println(map.size());
        System.out.println(map.get("1"));
        System.out.println(map.containsKey("1"));
        System.out.println(map.containsValue("Tom"));
        System.out.println(map.remove("1"));
        System.out.println(map.keySet());
        System.out.println(map.values());
        System.out.println(map.remove("2","Tom"));
        System.out.println(map);
        System.out.println(map.replace("3","Jack"));
        System.out.println(map);
    }
}
